RAIS  3.2
C:/Projekte/RAIS/common/RADEVClasses/EventMaster.cs
Go to the documentation of this file.
00001 
00002 
00003 
00004 using System;
00005 using System.Data;
00006 using System.Collections.Generic;
00007 
00008 namespace RAIS.Common.RADEVClasses
00009 {
00010     public class EventMaster : RADEVTable
00011     {
00012         #region fileds
00013         //protected const string commandString = "SELECT * FROM EventMaster";
00014                 protected const string commandString = "SELECT * FROM [RADEV Report - Event Master]()";
00015                 protected const string sourceName = "RADEVData_RADEV_Summary";
00016         private static List<RADEVTable> data = new List<RADEVTable>();
00017 
00018         string _eventDate = "";
00019         string _contactCrossRef = "";
00020         string _narrative = "";
00021         string _installationName = "";
00022         string _generalUseSector = "";
00023         string _specificPractice = "";
00024         string _detailOfPractice = "";
00025         string _correctiveAction = "";
00026         string _lessonsLearned = "";
00027         string _contactOrganization = "";
00028         string _region = "";
00029         string _facility = "";
00030 
00031         string _extOnSite = "";
00032         bool _extWidespread = false;
00033         string _eRLOrganisational = "";
00034         bool _eRLRegional = false;
00035         bool _eRLNational = false;
00036         bool _eRLBilateral = false;
00037         bool _eRLInternational = false;
00038         bool _sentToIAEA = false;
00039 
00040         string _countryCode = "";
00041         string _lastDateSentToIAEA = "";
00042         #endregion
00043 
00044         #region properties
00045 
00046 
00047 
00048         public string Facility { get { return _facility; } }
00052         public string ContactOrganization { get { return _contactOrganization; } }
00056         public string Region { get { return _region; } }
00060         public string CountryCode { get { return _countryCode; } }
00064         public string LastDateSentToIAEA { get { return _lastDateSentToIAEA; } }
00068                 public string ExtOnSite { get { return _extOnSite; } }
00072         public bool ExtWidespread { get { return _extWidespread; } }
00076         public string ERLOrganisational { get { return _eRLOrganisational; } }
00080         public bool ERLRegional { get { return _eRLRegional; } }
00084         public bool ERLNational { get { return _eRLNational; } }
00088         public bool ERLBilateral { get { return _eRLBilateral; } }
00092         public bool ERLInternational { get { return _eRLInternational; } }
00096         public string LessonsLearned { get { return _lessonsLearned; } }
00100         public string CorrectiveAction { get { return _correctiveAction; } }
00104         public string DetailOfPractice { get { return _detailOfPractice; } }
00108         public string SpecificPractice { get { return _specificPractice; } }
00112         public string GeneralUseSector { get { return _generalUseSector; } }
00116         public string InstallationName { get { return _installationName; } }
00120         public string Narrative { get { return _narrative; } }
00124         public string ContactCrossRef { get { return _contactCrossRef; } }
00128         public string EventDate { get { return _eventDate; } }
00129         #endregion
00130         #region Public methods
00131 
00132 
00133 
00134         public List<string> GenaralUseSectors 
00135                 { 
00136                         get 
00137                         { 
00138                                 List<string> generalUseSectors = new List<string>();
00139 
00140                                 string[] generalUseSectorArray = this._generalUseSector.Split(',');
00141                                 foreach (string generalUseSector in generalUseSectorArray)
00142                                         generalUseSectors.Add(generalUseSector.TrimStart());
00143 
00144                                 return generalUseSectors;
00145                         } 
00146                 }
00151         public static RADEVTable CreateInstatce()
00152         {
00153             data.Clear();
00154             return new EventMaster();
00155         }
00160         public override List<RADEVTable> GetData()
00161         {
00162             return data;
00163         }
00168         public override string GetSourceName()
00169         {
00170             return sourceName;
00171         }
00177         public override bool IsValid(RADEVCriterias criterias)
00178         {
00179             if (criterias.AllRecords)
00180                 return true;
00181             if (criterias.ContactOrganization != "")
00182                 return criterias.ContactOrganization == _contactOrganization;
00183 
00184             if (criterias.EndDate != DateTime.MinValue)
00185                 if (EventDate == "")
00186                     return criterias.EndDate >= DateTime.Now && criterias.StartDate >= DateTime.Now;
00187                 else
00188                     return criterias.EndDate >= DateTime.Parse(EventDate) && criterias.StartDate <= DateTime.Parse(EventDate);
00189 
00190             if (criterias.FromEvetnID != "")
00191                 return (IAEAEventID.CompareTo(criterias.FromEvetnID) == 1 
00192                                                 || IAEAEventID.CompareTo(criterias.FromEvetnID) == 0)
00193                                         && (IAEAEventID.CompareTo(criterias.ToEvetnID) == -1
00194                                                 || IAEAEventID.CompareTo(criterias.ToEvetnID) == 0);
00195 
00196             if (criterias.IAEARegion != "")
00197                 return _region == criterias.IAEARegion;
00198 
00199             if (criterias.InstalationName != "")
00200                 return InstallationName == criterias.InstalationName;
00201 
00202             if (criterias.SpecificPractice != "")
00203                 return GeneralUseSector.Contains(criterias.SpecificPractice);
00204 
00205             if (criterias.Facility != "")
00206                 return Facility == criterias.Facility;
00207 
00208 
00209             return false;
00210         }
00211         #endregion
00212 
00213 
00214 
00215 
00216         protected override void AddNewRow(IDataReader reader)
00217         {
00218             data.Add(new EventMaster(reader));
00219         }
00220         private EventMaster() { }
00221         protected EventMaster(IDataReader reader)
00222             : base((string)reader["IAEAEventID"])
00223         {
00224             _eventDate = reader["EventDate"] is DBNull ? "" : ((DateTime)reader["EventDate"]).ToString("yyyy.MM.dd");
00225             _contactCrossRef = reader["ContactCrossRef"] is DBNull ? "" : (string)reader["ContactCrossRef"];
00226             _narrative = reader["Narrative"] is DBNull ? "" : (string)reader["Narrative"];
00227             _installationName = reader["InstallationName"] is DBNull ? "" : (string)reader["InstallationName"];
00228             _generalUseSector = reader["GeneralUseSector"] is DBNull ? "" : (string)reader["GeneralUseSector"];
00229             _specificPractice = reader["SpecificPractice"] is DBNull ? "" : (string)reader["SpecificPractice"];
00230             _detailOfPractice = reader["DetailOfPractice"] is DBNull ? "" : (string)reader["DetailOfPractice"];
00231             _correctiveAction = reader["CorrectiveAction"] is DBNull ? "" : (string)reader["CorrectiveAction"];
00232             _lessonsLearned = reader["LessonsLearned"] is DBNull ? "" : (string)reader["LessonsLearned"];
00233             _contactOrganization = reader["ContactOrganization"] is DBNull ? "" : (string)reader["ContactOrganization"];
00234             _region = reader["Region"] is DBNull ? "" : (string)reader["Region"];
00235 
00236             _extOnSite = reader["ExtOnSite"] is DBNull ? "" : (string)reader["ExtOnSite"];
00237             _extWidespread = reader["ExtWidespread"] is DBNull ? false : (bool)reader["ExtWidespread"];
00238             _eRLOrganisational = reader["ERLOrganisational"] is DBNull ? "" : (string)reader["ERLOrganisational"];
00239             _eRLRegional = reader["ERLRegional"] is DBNull ? false : (bool)reader["ERLRegional"];
00240             _eRLNational = reader["ERLNational"] is DBNull ? false : (bool)reader["ERLNational"];
00241             _eRLBilateral = reader["ERLBilateral"] is DBNull ? false : (bool)reader["ERLBilateral"];
00242             _eRLInternational = reader["ERLInternational"] is DBNull ? false : (bool)reader["ERLInternational"];
00243 
00244             _lastDateSentToIAEA = reader["LastDateSentToIAEA"] is DBNull ? "" : ((DateTime)reader["LastDateSentToIAEA"]).ToString("yyyy.MM.dd");
00245 
00246             _countryCode = reader["CountryCode"] is DBNull ? "" : reader["CountryCode"].ToString();
00247 
00248             _sentToIAEA = reader["SentToIAEA"] is DBNull ? false : (bool)reader["SentToIAEA"];
00249 
00250             _facility = reader["Facility"] is DBNull ? "" : reader["Facility"].ToString();
00251         }
00252         protected override string GetCommandString()
00253         {
00254             return commandString;
00255         }
00256     }
00257 }